home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2632 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  55 lines

  1. Path: longwood.cs.ucf.edu!not-for-mail
  2. From: stevens@longwood.cs.ucf.edu (John Stevens)
  3. Newsgroups: comp.lang.c++
  4. Subject: STL, MSVC 4.0 and namespaces, can your code do this?
  5. Date: 18 Jan 1996 15:49:41 -0500
  6. Organization: University of Central Florida
  7. Message-ID: <4dmbp5$pjb@longwood.cs.ucf.edu>
  8. NNTP-Posting-Host: longwood.cs.ucf.edu
  9. Summary: Making STL work with MSVC & MFC, not!
  10. Keywords: STL MFC namespace
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. All,
  14.  
  15. I am interested in using the STL containers for a system which must be
  16. compilable with MFC code under MSVC 4.0. I have followed the instructions
  17. included by MS in the readme. They led me through setting up a namespace
  18. (std) for the STL, and touching the STL code to make sure that swap,
  19. allocate and and deallocate all had std namespace resolution added. I've
  20. done all this, and now comes the problem. When I compile, the compiler
  21. gives me the following error:
  22.  
  23. defalloc.h(124) : error C2660: 'new' : function does not take 2 parameters
  24.  
  25. on the following line of code (from the STL):
  26.  
  27. template <class T1, class T2>
  28. inline void construct(T1* p, const T2& value) {
  29.     new (p) T1(value); // here's the error line!
  30. }
  31.  
  32. I think that the namespace has somehow hidden the global new  operator (with
  33. placement syntax) from this call. I tried prepending :: to new, but got the
  34. same error. :-(
  35.  
  36. This is a sample which causes the trouble:
  37.  
  38. namespace std {
  39. #include <vector.h>
  40. }
  41.  
  42. int main() ;
  43. int main()
  44. {
  45.     std::vector<double> a ;
  46.  
  47.     a.push_back(1.0) ;
  48.     a.pop_back() ;
  49.     return 0 ;
  50. }
  51.  
  52. Help!!!! Have I stepped off the precipice of technology or what?
  53.  
  54. John S.
  55.